<?php
require_once 'models/model_manager.php';
require_once 'models/date_historique.php';

class date_historique_manager extends Manager
{	
	public function max_id() {
		$query = "SELECT max(idDate) FROM date_historique";
		$result = oci_parse($this->_db, $query);
		oci_execute($result);
		$r = oci_fetch_row($result);
		return $r[0];
	}
	
	public function add($e) {
		$query = 'INSERT INTO date_historique(idDate, reference, "DATE")
			VALUES (' . $e->get_iddate() . ',' . $e->get_reference() . ", to_date('" . $e->get_date() . "', 'DD/MM/SYYYY'))";
		$result = oci_parse($this->_db, $query);
		echo '<br>'. $query . '<br>';
		oci_execute($result);
	}
	
	public function delete($id) {
		$query = "DELETE FROM date_historique WHERE idDate = " . $id;
		$result = oci_parse($this->_db, $query);
		oci_execute($result);
	}
}
?>
